package com.x.chalk.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.x.chalk.dto.UsefulNewsDto;
import com.x.chalk.entity.UsefulNews;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
public interface UsefulNewsDao extends BaseMapper<UsefulNews> {
    @Update("update t_usefulnews set readnum=readnum+1 where id=#{id}")
    int updateRead(long id);

    @Update("update t_usefulnews set likes=likes+#{num} where id=#{id}")
    int updateLike(@Param("id") long id, @Param("num") int num);

    @Update("update t_usefulnews set comments=comments+#{num} where id=#{id}")
    int updateComment(@Param("id") Integer id,@Param("num") int num);

    long selectCount();
    List<UsefulNewsDto> usefulpage(@Param("start") int start, @Param("size") int size);

}
